package com.jy.adscm.serviceProvider.service.impl;

import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.security.utils.Token;
import com.jy.adscm.serviceProvider.bean.JyServiceType;
import com.jy.adscm.serviceProvider.mapper.JyServiceTypeMapper;
import com.jy.adscm.serviceProvider.service.JyServiceTypeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-01-24
 */
@Service
public class JyServiceTypeServiceImpl extends ServiceImpl<JyServiceTypeMapper, JyServiceType> implements JyServiceTypeService {
     @Transactional
    @Override
    public boolean insertJyServiceType(JyServiceType jyServiceType, Token token) throws AdscmSystemException {
        jyServiceType.setCreator(token.getUser().getId().toString());
        jyServiceType.setCreateTime(new Date());
        boolean insert = super.insert(jyServiceType);
        return insert;
    }
    @Transactional
    @Override
    public Boolean updateJyServiceType(JyServiceType jyServiceType, Token token) throws AdscmSystemException {
        boolean b = super.updateById(jyServiceType);

        return b;
    }

    @Override
    public List<JyServiceType> selectJyServiceType() throws AdscmSystemException {
        List<JyServiceType> jyServiceTypes = super.selectList(null);
        return jyServiceTypes;
    }
}
